#include <iostream>
#include <string>
#include <map>
using namespace std;

//输入明文
string init_Text(string& Password_Text)
{
	cout << "请输入明文：";
	getline(cin, Password_Text);
	return Password_Text;
}

//打印密文
void Print_Password_Text(char Print_Password[], string Password_size)
{
	int j = 0;
	for (j; j < Password_size.size();j++)
	{
		if (Print_Password[j] != ' ')
		{
			cout << Print_Password[j] << " ";
		}
		else {
			cout << " ";
		}
	}
}

void Print_Password_Text(int Print_Password[], string Password_size)
{
	int j = 0;
	for (j; j < Password_size.size(); j++)
	{
		if (Print_Password[j] != ' ')
		{
			cout << Print_Password[j] << " ";
		}
	}
}


void Init_Password_Bag(string Password_Text,int Password_Num[])
{
	map<char, int> password_list =
	{
		{'A', 0},
		{'B', 1},
		{'C', 2},
		{'D', 3},
		{'E', 4},
		{'F', 5},
	};
		
	for (int i = 0; i < Password_Text.size(); i++)
	{
	
		/*if (Password_Text[i] == ' ')
		{
			Password_Num[i] = ' ';
		}
		if (Password_Text[i] == 'A' || Password_Text[i] == 'a')
		{
			Password_Num[i] = 0;
		}
		if (Password_Text[i] == 'B' || Password_Text[i] == 'b')
		{
			Password_Num[i] = 1;
			
		}
		if (Password_Text[i] == 'C' || Password_Text[i] == 'c')
		{
			Password_Num[i] = 2;
			
		}
		if (Password_Text[i] == 'D' || Password_Text[i] == 'd')
		{
			Password_Num[i] = 3;
			
		}
		if (Password_Text[i] == 'E' || Password_Text[i] == 'e')
		{
			Password_Num[i] = 4;
		
		}
		if (Password_Text[i] == 'F' || Password_Text[i] == 'f')
		{
			Password_Num[i] = 5;
			
		}
		if (Password_Text[i] == 'G' || Password_Text[i] == 'g')
		{
			Password_Num[i] = 6;
		
		}
		if (Password_Text[i] == 'H' || Password_Text[i] == 'h')
		{
			Password_Num[i] = 7;
		
		}
		if (Password_Text[i] == 'I' || Password_Text[i] == 'i')
		{
			Password_Num[i] = 8;
		
		}
		if (Password_Text[i] == 'J' || Password_Text[i] == 'j')
		{
			Password_Num[i] = 9;
		
		}
		if (Password_Text[i] == 'K' || Password_Text[i] == 'k')
		{
			Password_Num[i] = 10;
		
		}
		if (Password_Text[i] == 'L' || Password_Text[i] == 'l')
		{
			Password_Num[i] = 11;
			
		}
		if (Password_Text[i] == 'M' || Password_Text[i] == 'm')
		{
			Password_Num[i] = 12;
		
		}
		if (Password_Text[i] == 'N' || Password_Text[i] == 'n')
		{
			Password_Num[i] = 13;
			
		}
		if (Password_Text[i] == 'O' || Password_Text[i] == 'o')
		{
			Password_Num[i] = 14;
			
		}
		if (Password_Text[i] == 'P' || Password_Text[i] == 'p')
		{
			Password_Num[i] = 15;
			
		}
		if (Password_Text[i] == 'Q' || Password_Text[i] == 'q')
		{
			Password_Num[i] = 16;
		}
		if (Password_Text[i] == 'R' || Password_Text[i] == 'r')
		{
			Password_Num[i] = 17;
		
		}
		if (Password_Text[i] == 'S' || Password_Text[i] == 's')
		{
			Password_Num[i] = 18;
		
		}
		if (Password_Text[i] == 'T' || Password_Text[i] == 't')
		{
			Password_Num[i] = 19;
		
		}
		if (Password_Text[i] == 'U' || Password_Text[i] == 'u')
		{
			Password_Num[i] = 20;
		
		}
		if (Password_Text[i] == 'V' || Password_Text[i] == 'v')
		{
			Password_Num[i] = 21;
		
		}
		if (Password_Text[i] == 'W' || Password_Text[i] == 'w')
		{
			Password_Num[i] = 22;
			
		}
		if (Password_Text[i] == 'X' || Password_Text[i] == 'x')
		{
			Password_Num[i] = 23;
			
		}
		if (Password_Text[i] == 'Y' || Password_Text[i] == 'y')
		{
			Password_Num[i] = 24;
		
		}
		if (Password_Text[i] == 'Z' || Password_Text[i] == 'z')
		{
			Password_Num[i] = 25;
		}*/
	}
}

//加密
void Add_Password(int Password_Num[], int AfterPassword_Num[], string Password_Size)
{
	int i = 0;
	for (i; i < Password_Size.size(); i++)
	{
		if (Password_Num[i] != -858993460)
		{
			AfterPassword_Num[i] = (Password_Num[i] +3) % 26;
		}
	}
	
}

//加密过后的密文
void Remove_Password(int AfterPassword_Num[], char Null_Password[],string Password_Size)
{
	for (int i = 0; i < Password_Size.size(); i++)
	{
		if (AfterPassword_Num[i] == 0)
		{
			Null_Password[i] = 'A';

		}
		if (AfterPassword_Num[i] == 1)
		{
			Null_Password[i] = 'B';

		}
		if (AfterPassword_Num[i] == 2)
		{
			Null_Password[i] = 'C';

		}
		if (AfterPassword_Num[i] == 3)
		{
			Null_Password[i] = 'D';

		}
		if (AfterPassword_Num[i] == 4)
		{
			Null_Password[i] = 'E';

		}
		if (AfterPassword_Num[i] == 5)
		{
			Null_Password[i] = 'F';

		}
		if (AfterPassword_Num[i] == 6)
		{
			Null_Password[i] = 'G';

		}
		if (AfterPassword_Num[i] == 7)
		{
			Null_Password[i] = 'H';

		}
		if (AfterPassword_Num[i] == 8)
		{
			Null_Password[i] = 'I';

		}
		if (AfterPassword_Num[i] == 9)
		{
			Null_Password[i] = 'J';

		}
		if (AfterPassword_Num[i] == 10)
		{
			Null_Password[i] = 'K';

		}
		if (AfterPassword_Num[i] == 11)
		{
			Null_Password[i] = 'L';

		}
		if (AfterPassword_Num[i] == 12)
		{
			Null_Password[i] = 'M';

		}
		if (AfterPassword_Num[i] == 13)
		{
			Null_Password[i] = 'N';

		}
		if (AfterPassword_Num[i] == 14)
		{
			Null_Password[i] = 'O';

		}
		if (AfterPassword_Num[i] == 15)
		{
			Null_Password[i] = 'P';

		}
		if (AfterPassword_Num[i] == 16)
		{
			Null_Password[i] = 'Q';
		}
		if (AfterPassword_Num[i] == 17)
		{
			Null_Password[i] = 'R';

		}
		if (AfterPassword_Num[i] == 18)
		{
			Null_Password[i] = 'S';

		}
		if (AfterPassword_Num[i] == 19)
		{
			Null_Password[i] = 'T';

		}
		if (AfterPassword_Num[i] == 20)
		{
			Null_Password[i] = 'U';

		}
		if (AfterPassword_Num[i] == 21)
		{
			Null_Password[i] = 'V';

		}
		if (AfterPassword_Num[i] == 22)
		{
			Null_Password[i] = 'W';

		}
		if (AfterPassword_Num[i] == 23)
		{
			Null_Password[i] = 'X';

		}
		if (AfterPassword_Num[i] == 24)
		{
			Null_Password[i] = 'Y';

		}
		if (AfterPassword_Num[i] == 25)
		{
			Null_Password[i] = 'Z';
		}
	}
}

int main()
{
	string Password_Text;
	char Null_Password[100];
	int Password_Num[100];

	//输入明文
	init_Text(Password_Text);
	//给每个字母赋予一个数字
	Init_Password_Bag(Password_Text, Password_Num);
	

	int AfterPassword_Num[100];
	cout << "该明文用数字表示为：";
	Print_Password_Text(Password_Num, Password_Text);
	cout << endl;

	
	Add_Password(Password_Num, AfterPassword_Num, Password_Text);
	cout << "得到密文对应的数字表示为:";

	
	Print_Password_Text(AfterPassword_Num,Password_Text);
	cout << endl;

	Remove_Password(AfterPassword_Num, Null_Password, Password_Text);
	cout << "得到密文为：";
	Print_Password_Text(Null_Password, Password_Text);
	cout << endl;
	
	system("pause");
	return 0;
}